package com.dmpp.mes.controller;


import com.dmpp.mes.bean.ResponseData;
import com.dmpp.mes.parameterInfo.Category;
import com.dmpp.mes.parameterInfo.DeviceCategory;
import com.dmpp.mes.service.CategoryService;
import com.dmpp.mes.service.DeviceCategoryService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("Category")
public class CategoryController {
//原材料材质分类  半成品类别 成品类型
    @Autowired
    private CategoryService service;


    @RequestMapping(value = "/FindAll", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData findAll(Integer page, Integer pageSize,Category category) {
        PageHelper.startPage(page, pageSize);
        return service.findAll(category);
    }

    @RequestMapping(value = "/FindByCode", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData findByCode(Category category) {
        return service.findByCode(category);
    }

    @RequestMapping(value = "/Insert", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData insert(Category category) {
        return service.insert(category);
    }

    @RequestMapping(value = "/UpdateByCode", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData updateByCode(Category category) {
        return service.updateByCode(category);
    }

    @RequestMapping(value = "/DeleteByCode", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData deleteByCode(Category category) {
        return service.deleteByCode(category);
    }

    @RequestMapping(value = "/Delete", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData delete(Category category) {
        return service.delete(category);
    }

}
